//封装获取频道列表的逻辑
import { useState, useEffect } from 'react'
import { getChannelListAPI } from '@/apis/article'
function useChannels() {
    //获取频道列表
    //获取频道列表
    const [channelList, setChannelList] = useState([])
    useEffect(() => {
        //封装函数  在函数中调用接口
        const getChannelList = async () => {
            const res = await getChannelListAPI()
            setChannelList(res.data.channels)
        }
        //调用函数
        getChannelList();
    }, [])
    //把组件中数据return
    return{
        channelList
    }
}

export { useChannels }